package com.jm.product.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.google.common.collect.Lists;

/**
 * 商品品牌Entity
 * @author sunshine
 * @version 2017-07-03
 */
@Entity
@Table(name = "es_brand")
@Cache(region = "com.jm.cache", usage = CacheConcurrencyStrategy.READ_WRITE)
public class Brand extends IdEntity<Integer> implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
    @Column(name="name")
	private String name;//品牌名称
    @Column(name="logo")
	private String logo;//品牌LOGO
    @Column(name="keywords")
	private String keywords;//keywords
    @Column(name="brief")
	private String brief;//brief
    @Column(name="url")
	private String url;//品牌网址
    @Column(name="disabled")
	private String disabled;//disabled
    @OneToMany(mappedBy = "brand",orphanRemoval=true,
    		cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<TypeBrandMap> typeBrandMap = Lists.newArrayList() ;

	public Brand() {
		super();
	}
	
	/**
	*
	* get 品牌名称
	*
	* return name
	*/
	public String getName() {
		return this.name;
	}
	
	/**
	 * 
	 * set 品牌名称
	 * 
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	*
	* get 品牌LOGO
	*
	* return logo
	*/
	public String getLogo() {
		return this.logo;
	}
	
	/**
	 * 
	 * set 品牌LOGO
	 * 
	 * @param logo
	 */
	public void setLogo(String logo) {
		this.logo = logo;
	}
	/**
	*
	* get keywords
	*
	* return keywords
	*/
	public String getKeywords() {
		return this.keywords;
	}
	
	/**
	 * 
	 * set keywords
	 * 
	 * @param keywords
	 */
	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}
	/**
	*
	* get brief
	*
	* return brief
	*/
	public String getBrief() {
		return this.brief;
	}
	
	/**
	 * 
	 * set brief
	 * 
	 * @param brief
	 */
	public void setBrief(String brief) {
		this.brief = brief;
	}
	/**
	*
	* get 品牌网址
	*
	* return url
	*/
	public String getUrl() {
		return this.url;
	}
	
	/**
	 * 
	 * set 品牌网址
	 * 
	 * @param url
	 */
	public void setUrl(String url) {
		this.url = url;
	}
	/**
	*
	* get disabled
	*
	* return disabled
	*/
	public String getDisabled() {
		return this.disabled;
	}
	
	/**
	 * 
	 * set disabled
	 * 
	 * @param disabled
	 */
	public void setDisabled(String disabled) {
		this.disabled = disabled;
	}

	public List<TypeBrandMap> getTypeBrandMap() {
		return typeBrandMap;
	}

	public void setTypeBrandMap(List<TypeBrandMap> typeBrandMap) {
		this.typeBrandMap = typeBrandMap;
	}

	@Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        result = prime * result + ((logo == null) ? 0 : logo.hashCode());
        result = prime * result + ((keywords == null) ? 0 : keywords.hashCode());
        result = prime * result + ((brief == null) ? 0 : brief.hashCode());
        result = prime * result + ((url == null) ? 0 : url.hashCode());
        result = prime * result + ((disabled == null) ? 0 : disabled.hashCode());
        return result;
    }
	
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Brand other = (Brand) obj;
        if (id == null) {
            if (other.id != null)
                return false;
        } else if (!id.equals(other.id))
            return false;
        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;
        if (logo == null) {
            if (other.logo != null)
                return false;
        } else if (!logo.equals(other.logo))
            return false;
        if (keywords == null) {
            if (other.keywords != null)
                return false;
        } else if (!keywords.equals(other.keywords))
            return false;
        if (brief == null) {
            if (other.brief != null)
                return false;
        } else if (!brief.equals(other.brief))
            return false;
        if (url == null) {
            if (other.url != null)
                return false;
        } else if (!url.equals(other.url))
            return false;
        if (disabled == null) {
            if (other.disabled != null)
                return false;
        } else if (!disabled.equals(other.disabled))
            return false;
        return true;
    }
	
 	@Override
    public String toString() {
        return "Brand [id=" + id + ",name=" + name + ",logo=" + logo + ",keywords=" + keywords + ",brief=" + brief + ",url=" + url + ",disabled=" + disabled + "]";
    }
}


